
cc.Class({
    extends: require('UI-PanelWindow'),

    properties: {
        count:cc.Label,
        coinBtn:cc.Node,
        coinNumber:cc.Label,
        planeBtn:cc.Node,
        tip:cc.Label,
    },

    // LIFE-CYCLE CALLBACKS:

    onLoad () {
        this._super();
        var getCount=global.Data.signIn;
        this.count.string=!global.Data.signIn.isSign?'每日签到(第'+getCount.signCount+'天)':'已签到';
        this.coinNumber.string=global.Common.getKV(global.Data.signIn.goldCoin)
        if(getCount.signCount==3 || getCount.signCount==7){
            this.tip.string=!global.Data.signIn.isSign?'可领取':'已领取';
            this.coinBtn.active=false;
            this.planeBtn.active=true;
        }else{
            this.coinBtn.active=true;
            this.planeBtn.active=false;
            if(getCount.signCount<3){
                this.tip.string='第3日可领取';
            }else{
                this.tip.string='第7日可领取';
            }
        }
    },

    start () {
       
    },

    onClickGetCoin(){
        this.get();
    },

    onClickGetPlane(){
        this.get();
    },

    get(){
        var self=this;
        if(!global.Data.signIn.isSign){
            global.Platform.showVideo('adunit-fde87010347b6b31',function(finish){
                if(finish){
                    let router='signIn.receive'
                    self.httpGet('/game/gameUser',router,{},function(err,res){
                        global.Data.store.goldCoin +=global.Data.signIn.goldCoin;
                        global.Data.signIn.isSign=true;
                        if((global.Data.signIn.signCount==3 || global.Data.signIn.signCount==7)){
                            var number=global.Data.signIn.signCount==3?1:2;
                            global.Data.plane.currentPlane=number
                            global.noVideoPlane=number
                            global.Event.emit('changePlane',{data:number})
                        }
                    })
                    global.Event.emit('signed')
                    self.onClickCancle();
                }
            })
        }else{
            global.EJMgr.showToast('已签到，请勿重复签到');
            self.onClickCancle();
        }
        
    },

    onClickCancle(){
        global.EJMgr.popUI();
    },

    // update (dt) {},
});
